<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改应用')" />
    <th:block th:include="include :: ztree-css" />
    <th:block th:include="include :: select2-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-role-add">
        <div class="form-group">
            <input name="id" th:value="${id}"  hidden id = "id">
            <label class="col-sm-3 control-label is-required">应用分组：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="longGroupName" id="longGroupName" required>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label is-required">服务器列表：</label>
            <div class="col-xs-8">
                <input class="form-control" type="text" name="serverIpListStr" id="serverIpListStr" required>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label is-required">应用名称：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="appName" id="appName" required>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label is-required">应用编码：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="appCode" id="appCode" required>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label is-required">包全路径名称：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="appPath" id="appPath" required>
            </div>
        </div>


        <div class="form-group">
            <label class="col-sm-3 control-label is-required">日志路径：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="logPath" id="logPath" required>
            </div>
        </div>



        <div class="form-group">
            <label class="col-sm-3 control-label is-required">负责人：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="appPrincipal" id="appPrincipal" required>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">描述：</label>
            <div class="col-sm-8">
                <input id="groupDes" name="appDesc" class="form-control" type="appDesc">
            </div>
        </div>


        <h4 class="form-header h4">命令管理</h4>

        <div class="form-group">
            <label class="col-sm-3 control-label is-required">启动命令：</label>
            <div class="col-sm-8">
                <div class="input-group">
                    <input class="form-control" type="text" name="startCmd" id="startCmd" required>
                    <span class="input-group-btn">
                        <button type="button" class="btn btn-circle" data-toggle="tooltip" title="建议启动命令可以封装成一个脚本存储在服务器，这边存放调用脚本的命令"> <i class="fa fa-question"></i></button>
                    </span>
                </div>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label is-required">停止命令：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="stopCmd" id="stopCmd" required>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label is-required">重启命令：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="restartCmd" id="restartCmd" required>
            </div>
        </div>


        <h4 class="form-header h4">变量配置</h4>


    </form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: ztree-js" />
<th:block th:include="include :: select2-js" />
<script type="text/javascript">

    $(function() {

        initFrom();
    });

    function initFrom(){
        $.modal.loading("数据加载中...")
        $.operate.ajaxGet(ctx+"app/getDetail?id="+$('#id').val(),function (res) {
            $.each(res, function(key, value) {
                console.log("表单初始化开始")
                var element = $('[name="' + key + '"]');
                if(element.length > 0){
                    if(element.is('select') && element.is('[multiple]')){
                        element.val(value.split(",")).trigger('change');
                    }else {
                        element.val(value);
                    }
                }
                //禁止编辑
                $('#form-role-add :input').prop('disabled', true);
                $.modal.closeLoading();
            });
        })
    }





</script>
</body>
</html>
